import 'dart:ui';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:flutter_module/global/colors.dart';
import 'package:flutter_module/pages/sec_page.dart';
import 'package:flutter_module/pages/three_page.dart';
import 'package:flutter_module/utils/method_channel_plugin.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_screenutil/screen_util.dart';
import 'Dialogs.dart';

class MyPage extends StatefulWidget {
  @override
  _MyPageState createState() => _MyPageState();
}

class _MyPageState extends State<MyPage> {
  bool _display=false;
  @override
  void initState() {
    super.initState();
    _loadData();
  }

  void _loadData() async {
    EasyLoading.show(
      status: "Loading...",
      //duration: Duration(seconds: 2)
      //maskType: EasyLoadingMaskType.black,
    );
    await Future.delayed(Duration(milliseconds: 1000), () async {
      EasyLoading.dismiss();
      setState(() {
        _display=true;
      });
    });

  }
  @override
  Widget build(BuildContext context) {
    ScreenUtil.init(
      BoxConstraints(
          maxWidth: MediaQuery.of(context).size.width,
          maxHeight: MediaQuery.of(context).size.height),
      designSize: Size(1080, 2340),
    );
    if(_display==true) {
      return Container(
        width: double.infinity,
        height: double.infinity,
        color: Color(0xff000B1F),
        child: Column(
          children: [
            Container(
              width: ScreenUtil().screenWidth - ScreenUtil().setWidth(108),
              height: ScreenUtil().setHeight(192),
              margin: EdgeInsets.fromLTRB(
                ScreenUtil().setWidth(54),
                ScreenUtil().setHeight(110),
                ScreenUtil().setWidth(54),
                ScreenUtil().setHeight(0),
              ),
              child: Row(
                children: [
                  ClipOval(
                    child: Image.network(
                        "https://img2.baidu.com/it/u=172917783,2425047487&fm=26&fmt=auto",
                        width: ScreenUtil().setHeight(192),
                        height: ScreenUtil().setHeight(192),
                        fit: BoxFit.cover),
                  ),
                  SizedBox(
                    width: ScreenUtil().setWidth(32),
                  ),
                  Column(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: [
                      Text(
                        'seiegeLion',
                        style: TextStyle(
                          fontSize: ScreenUtil().setSp(60),
                          color: Colors.white,
                        ),
                      ),
                      Text(
                        'id:1216',
                        style: TextStyle(
                          fontSize: ScreenUtil().setSp(50),
                          color: Colors.white,
                        ),
                      ),
                    ],
                  ),
                  Expanded(
                      child: Align(
                        alignment: Alignment.centerRight,
                        child: Image.asset(
                          'assets/images/back.png',
                          width: ScreenUtil().setHeight(28),
                          height: ScreenUtil().setHeight(46),
                          fit: BoxFit.cover,
                        ),
                      ))
                ],
              ),
            ),
            Container(
              decoration: BoxDecoration(
                color: Color(0xff081327),
                borderRadius: BorderRadius.all(Radius.circular(10)),
              ),
              width: ScreenUtil().screenWidth - ScreenUtil().setWidth(28 * 2),
              height: ScreenUtil().setHeight(596 * 0.5),
              margin: EdgeInsets.fromLTRB(
                ScreenUtil().setWidth(28),
                ScreenUtil().setHeight(58),
                ScreenUtil().setWidth(28),
                ScreenUtil().setHeight(0),
              ),
              padding: EdgeInsets.fromLTRB(
                ScreenUtil().setWidth(56),
                ScreenUtil().setHeight(46),
                ScreenUtil().setWidth(56),
                ScreenUtil().setHeight(0),
              ),
              child: Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [
                  InkWell(
                    onTap: (){
                      Navigator.pushNamed(context, 'yue');
                    },
                    child: Container(
                      width: ScreenUtil().setWidth(160),
                      height: ScreenUtil().setHeight(228),
                      child: Column(
                        mainAxisAlignment: MainAxisAlignment.spaceBetween,
                        children: [
                          Image.asset(
                            'assets/images/my_wallet.png',
                            width: ScreenUtil().setWidth(160),
                            height: ScreenUtil().setWidth(160),
                            fit: BoxFit.cover,
                          ),
                          Text(
                            '我的钱包',
                            style: TextStyle(
                              fontSize: 14,
                              color: Colors.white,
                            ),
                          )
                        ],
                      ),
                    ),
                  ),
                  InkWell(
                    onTap: (){
                      Navigator.pushNamed(context, 'myNTF');
                    },
                    child: Container(
                      width: ScreenUtil().setWidth(160),
                      height: ScreenUtil().setHeight(228),
                      child: Column(
                        mainAxisAlignment: MainAxisAlignment.spaceBetween,
                        children: [
                          Image.asset(
                            'assets/images/my_nft.png',
                            width: ScreenUtil().setWidth(160),
                            height: ScreenUtil().setWidth(160),
                            fit: BoxFit.cover,
                          ),
                          Text(
                            '我的NFT',
                            style: TextStyle(
                              fontSize: 14,
                              color: Colors.white,
                            ),
                          )
                        ],
                      ),
                    ),
                  ),
                  InkWell(
                    onTap: (){
                      showUploadDialog(context);
                    },
                    child: Container(
                      width: ScreenUtil().setWidth(160),
                      height: ScreenUtil().setHeight(228),
                      child: Column(
                        mainAxisAlignment: MainAxisAlignment.spaceBetween,
                        children: [
                          Image.asset(
                            'assets/images/upload_nft.png',
                            width: ScreenUtil().setWidth(160),
                            height: ScreenUtil().setWidth(160),
                            fit: BoxFit.cover,
                          ),
                          Text(
                            '上传NFT',
                            style: TextStyle(
                              fontSize: 14,
                              color: Colors.white,
                            ),
                          )
                        ],
                      ),
                    ),
                  ),
                  Container(
                    width: ScreenUtil().setWidth(160),
                    height: ScreenUtil().setHeight(228),
                    child: Column(
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      children: [
                        Image.asset(
                          'assets/images/shop_order.png',
                          width: ScreenUtil().setWidth(160),
                          height: ScreenUtil().setWidth(160),
                          fit: BoxFit.cover,
                        ),
                        Text(
                          '商城订单',
                          style: TextStyle(
                            fontSize: 14,
                            color: Colors.white,
                          ),
                        )
                      ],
                    ),
                  ),
                ],
              ),
            ),

            //我的收藏
            Container(
              margin: EdgeInsets.fromLTRB(
                ScreenUtil().setWidth(28),
                ScreenUtil().setHeight(36),
                ScreenUtil().setWidth(28),
                ScreenUtil().setHeight(0),
              ),
              padding: EdgeInsets.fromLTRB(
                ScreenUtil().setWidth(36),
                ScreenUtil().setHeight(0),
                ScreenUtil().setWidth(32),
                ScreenUtil().setHeight(0),
              ),
              decoration: BoxDecoration(
                color: Color(0xff081327),
              ),
              height: ScreenUtil().setHeight(170),
              child: Row(
                children: [
                  Image.asset(
                    'assets/images/shoucang.png',
                    width: ScreenUtil().setHeight(56),
                    height: ScreenUtil().setHeight(62),
                    fit: BoxFit.cover,
                  ),
                  SizedBox(
                    width: ScreenUtil().setWidth(36),
                  ),
                  Text(
                    '我的收藏',
                    style: TextStyle(
                      fontSize: 14,
                      color: Colors.white,
                    ),
                  ),
                  Expanded(
                    child: Align(
                      alignment: Alignment.centerRight,
                      child: Image.asset(
                        'assets/images/back.png',
                        width: ScreenUtil().setWidth(28),
                        height: ScreenUtil().setHeight(46),
                        fit: BoxFit.cover,
                      ),
                    ),
                  ),
                ],
              ),
            ),
            //账号信息
            Container(
              margin: EdgeInsets.fromLTRB(
                ScreenUtil().setWidth(28),
                ScreenUtil().setHeight(16),
                ScreenUtil().setWidth(28),
                ScreenUtil().setHeight(0),
              ),
              padding: EdgeInsets.fromLTRB(
                ScreenUtil().setWidth(36),
                ScreenUtil().setHeight(0),
                ScreenUtil().setWidth(32),
                ScreenUtil().setHeight(0),
              ),
              decoration: BoxDecoration(
                color: Color(0xff081327),
              ),
              height: ScreenUtil().setHeight(170),
              child: Row(
                children: [
                  Image.asset(
                    'assets/images/zhanghao.png',
                    width: ScreenUtil().setHeight(56),
                    height: ScreenUtil().setHeight(62),
                    fit: BoxFit.cover,
                  ),
                  SizedBox(
                    width: ScreenUtil().setWidth(36),
                  ),
                  Text(
                    '账号信息',
                    style: TextStyle(
                      fontSize: 14,
                      color: Colors.white,
                    ),
                  ),
                  Expanded(
                    child: Align(
                      alignment: Alignment.centerRight,
                      child: Image.asset(
                        'assets/images/back.png',
                        width: ScreenUtil().setWidth(28),
                        height: ScreenUtil().setHeight(46),
                        fit: BoxFit.cover,
                      ),
                    ),
                  ),
                ],
              ),
            ),
            //练习客服
            Container(
              margin: EdgeInsets.fromLTRB(
                ScreenUtil().setWidth(28),
                ScreenUtil().setHeight(16),
                ScreenUtil().setWidth(28),
                ScreenUtil().setHeight(0),
              ),
              padding: EdgeInsets.fromLTRB(
                ScreenUtil().setWidth(36),
                ScreenUtil().setHeight(0),
                ScreenUtil().setWidth(32),
                ScreenUtil().setHeight(0),
              ),
              decoration: BoxDecoration(
                color: Color(0xff081327),
              ),
              height: ScreenUtil().setHeight(170),
              child: Row(
                children: [
                  Image.asset(
                    'assets/images/kefu.png',
                    width: ScreenUtil().setHeight(56),
                    height: ScreenUtil().setHeight(62),
                    fit: BoxFit.cover,
                  ),
                  SizedBox(
                    width: ScreenUtil().setWidth(36),
                  ),
                  Text(
                    '联系客服',
                    style: TextStyle(
                      fontSize: 14,
                      color: Colors.white,
                    ),
                  ),
                  Expanded(
                    child: Align(
                      alignment: Alignment.centerRight,
                      child: Image.asset(
                        'assets/images/back.png',
                        width: ScreenUtil().setWidth(28),
                        height: ScreenUtil().setHeight(46),
                        fit: BoxFit.cover,
                      ),
                    ),
                  ),
                ],
              ),
            ),
            //设置
            Container(
              margin: EdgeInsets.fromLTRB(
                ScreenUtil().setWidth(28),
                ScreenUtil().setHeight(16),
                ScreenUtil().setWidth(28),
                ScreenUtil().setHeight(0),
              ),
              padding: EdgeInsets.fromLTRB(
                ScreenUtil().setWidth(36),
                ScreenUtil().setHeight(0),
                ScreenUtil().setWidth(32),
                ScreenUtil().setHeight(0),
              ),
              decoration: BoxDecoration(
                color: Color(0xff081327),
              ),
              height: ScreenUtil().setHeight(170),
              child: Row(
                children: [
                  Image.asset(
                    'assets/images/setting.png',
                    width: ScreenUtil().setHeight(56),
                    height: ScreenUtil().setHeight(62),
                    fit: BoxFit.cover,
                  ),
                  SizedBox(
                    width: ScreenUtil().setWidth(36),
                  ),
                  Text(
                    '设置',
                    style: TextStyle(
                      fontSize: 14,
                      color: Colors.white,
                    ),
                  ),
                  Expanded(
                    child: Align(
                      alignment: Alignment.centerRight,
                      child: Image.asset(
                        'assets/images/back.png',
                        width: ScreenUtil().setWidth(28),
                        height: ScreenUtil().setHeight(46),
                        fit: BoxFit.cover,
                      ),
                    ),
                  ),
                ],
              ),
            ),
            //分享应用
            Container(
              margin: EdgeInsets.fromLTRB(
                ScreenUtil().setWidth(28),
                ScreenUtil().setHeight(16),
                ScreenUtil().setWidth(28),
                ScreenUtil().setHeight(0),
              ),
              padding: EdgeInsets.fromLTRB(
                ScreenUtil().setWidth(36),
                ScreenUtil().setHeight(0),
                ScreenUtil().setWidth(32),
                ScreenUtil().setHeight(0),
              ),
              decoration: BoxDecoration(
                color: Color(0xff081327),
              ),
              height: ScreenUtil().setHeight(170),
              child: Row(
                children: [
                  Image.asset(
                    'assets/images/share.png',
                    width: ScreenUtil().setHeight(56),
                    height: ScreenUtil().setHeight(62),
                    fit: BoxFit.cover,
                  ),
                  SizedBox(
                    width: ScreenUtil().setWidth(36),
                  ),
                  Text(
                    '分享应用',
                    style: TextStyle(
                      fontSize: 14,
                      color: Colors.white,
                    ),
                  ),
                  Expanded(
                    child: Align(
                      alignment: Alignment.centerRight,
                      child: Image.asset(
                        'assets/images/back.png',
                        width: ScreenUtil().setWidth(28),
                        height: ScreenUtil().setHeight(46),
                        fit: BoxFit.cover,
                      ),
                    ),
                  ),
                ],
              ),
            ),
            //清理缓存
            Container(
              margin: EdgeInsets.fromLTRB(
                ScreenUtil().setWidth(28),
                ScreenUtil().setHeight(16),
                ScreenUtil().setWidth(28),
                ScreenUtil().setHeight(0),
              ),
              padding: EdgeInsets.fromLTRB(
                ScreenUtil().setWidth(36),
                ScreenUtil().setHeight(0),
                ScreenUtil().setWidth(32),
                ScreenUtil().setHeight(0),
              ),
              decoration: BoxDecoration(
                color: Color(0xff081327),
              ),
              height: ScreenUtil().setHeight(170),
              child: Row(
                children: [
                  Image.asset(
                    'assets/images/huancun.png',
                    width: ScreenUtil().setHeight(56),
                    height: ScreenUtil().setHeight(62),
                    fit: BoxFit.cover,
                  ),
                  SizedBox(
                    width: ScreenUtil().setWidth(36),
                  ),
                  Text(
                    '清理缓存',
                    style: TextStyle(
                      fontSize: 14,
                      color: Colors.white,
                    ),
                  ),
                  Expanded(
                    child: Align(
                      alignment: Alignment.centerRight,
                      child: Image.asset(
                        'assets/images/back.png',
                        width: ScreenUtil().setWidth(28),
                        height: ScreenUtil().setHeight(46),
                        fit: BoxFit.cover,
                      ),
                    ),
                  ),
                ],
              ),
            ),
          ],
        ),
      );
    }else{
      return Container(
        width: 0,
        height: 0,
        color: AppColors.background,
      );
    }

  }
}
